//
//  MoreFuncViewController.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/5/24.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "MoreFuncViewController.h"
#import "MoreHeadView.h"

static NSInteger BTN_INDEX_TAG = 300;

@interface MoreFuncViewController ()

@property (nonatomic,strong) MoreHeadView *headView;

@property (nonatomic,strong) NSArray *btnTitleArray;

@end

@implementation MoreFuncViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _btnTitleArray = @[@"数据迁移",@"设置",@"关于我们"];
    [self configUI];
}
- (void)configUI{
    self.view.backgroundColor = [UIColor qmui_colorWithHexString:@"#F6F6F6"];
    [self.view addSubview:self.headView];
    int i = 0;
    for (NSString *str in _btnTitleArray) {
        QMUIButton *btn = [[QMUIButton alloc]qmui_initWithImage:UIImageMake(str) title:str];
        [btn setTitleColor:[UIColor qmui_colorWithHexString:@"#112D55"] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:12];
        btn.backgroundColor = [UIColor whiteColor];
        btn.imagePosition = QMUIButtonImagePositionTop;
        btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 5, 0);
        btn.titleEdgeInsets = UIEdgeInsetsMake(5, 0, 0, 0);
        btn.tag = BTN_INDEX_TAG + i;
        i++;
        [self.view addSubview:btn];
    }
}
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.height.equalTo(@230);
    }];
    CGFloat btnWidth = SCREEN_WIDTH/3;
    for (int i = 0; i<3; i++) {
        UIView *view = [self.view viewWithTag:BTN_INDEX_TAG+i];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(i*btnWidth));
            make.width.equalTo(@(btnWidth));
            make.top.equalTo(_headView.mas_bottom).offset(15);
            make.height.equalTo(@(btnWidth*1.2));
        }];
    }
}
- (MoreHeadView *)headView{
    if (!_headView) {
        _headView = [[MoreHeadView alloc]init];
    }
    return _headView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
